//
//  YQImportWalletVC.m
//  NewRetail
//
//  Created by yuqin on 2019/6/29.
//  Copyright © 2019年 yuqin. All rights reserved.
//

#import "YQImportWalletVC.h"
#import "YQServerTermsView.h"

@interface YQImportWalletVC ()

@property (nonatomic, strong) UIView *backView;
@property (nonatomic, strong) UITextField *pwdTF;
@property (nonatomic, strong) UIView *textFieldBackView;
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) YQServerTermsView *serverView;
@property (nonatomic, strong) UIButton *keystoreBtn;
@property (nonatomic, strong) UIButton *importWalletBtn;

@end

@implementation YQImportWalletVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.txtTitle.text = @"导入钱包";
    [self setupRightBtn];
    [self setupImprotView];
}

- (void)setupImprotView {
    [self.view addSubview:self.backView];
    [self.backView addSubview:self.textView];
    [self.view addSubview:self.textFieldBackView];
    [self.textFieldBackView addSubview:self.pwdTF];
    [self.view addSubview:self.serverView];
    [self.view addSubview:self.keystoreBtn];
    [self.view addSubview:self.importWalletBtn];
    
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.top.equalTo(self.headView.mas_bottom).mas_equalTo(FIT(20));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-2*kMargin_left, FIT(150)));
    }];
    
    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.top.mas_equalTo(kMargin_left);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-4*kMargin_left, FIT(114)));
    }];
    
    [self.textFieldBackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.top.equalTo(self.backView.mas_bottom).mas_equalTo(FIT(20));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-2*kMargin_left, FIT(50)));
    }];
    
    [self.pwdTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.top.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-4*kMargin_left, FIT(50)));
    }];
    
    [self.serverView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.equalTo(self.pwdTF.mas_bottom).mas_equalTo(FIT(20));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, FIT(15)));
    }];
    
    [self.keystoreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.bottom.mas_equalTo(-Botoom_IPhoneX-FIT(40));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-2*kMargin_left, FIT(16)));
    }];
    
    [self.importWalletBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.bottom.equalTo(self.keystoreBtn.mas_top).mas_equalTo(-FIT(20));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-2*kMargin_left, kCommitButtonHeight));
    }];
    
}

- (void)setupRightBtn {
    UIButton *imgBtn = [YQViewFactory buttonWithImage:YQ_IMAGE(@"scan_white") target:self sel:@selector(scanningAction)];
    [self.headView addSubview:imgBtn];
    [imgBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-FIT(14));
        make.bottom.mas_equalTo(-FIT(14));
        make.size.mas_equalTo(CGSizeMake(FIT(24), FIT(24)));
    }];
}

- (UIView *)backView {
    if (!_backView) {
        _backView = [[UIView alloc] init];
        _backView.backgroundColor = UIColorFromRGB(0xf5f5f5);
        _backView.layer.cornerRadius = 5;
        _backView.layer.masksToBounds = YES;
    }
    return _backView;
}

- (UITextView *)textView {
    if (!_textView) {
        _textView = [[UITextView alloc] init];
        _textView.backgroundColor = UIColorFromRGB(0xf5f5f5);
        _textView.font = YQ_Font(FIT(18));
        _textView.placeholder = @"Keystore文本内容";
        _textView.limitLength = @200;
        
    }
    return _textView;
}

- (UIView *)textFieldBackView {
    if (!_textFieldBackView) {
        _textFieldBackView = [[UIView alloc] init];
        _textFieldBackView.backgroundColor = UIColorFromRGB(0xf5f5f5);
        _textFieldBackView.layer.cornerRadius = 7;
        _textFieldBackView.layer.masksToBounds = YES;
    }
    return _textFieldBackView;
}

- (UITextField *)pwdTF {
    if (!_pwdTF) {
        _pwdTF = [YQViewFactory textFieldWithPlaceholderText:@"请输入密码" textColor:MainBlackColor fontSize:FIT(18) userBold:NO];
        _pwdTF.borderStyle = UITextBorderStyleNone;
        _pwdTF.backgroundColor = UIColorFromRGB(0xf5f5f5);
    }
    return _pwdTF;
}

- (YQServerTermsView *)serverView {
    if (!_serverView) {
        _serverView = [[YQServerTermsView alloc] init];
        //各种block
    }
    return _serverView;
}

- (UIButton *)keystoreBtn {
    if (!_keystoreBtn) {
        _keystoreBtn = [YQViewFactory buttonWithTitle:@"什么是Keystore？" titleColor:NormalButtonColor fontSize:FIT(15) userBold:NO target:self sel:@selector(showKeystoreAction)];
    }
    return _keystoreBtn;
}

- (UIButton *)importWalletBtn {
    if (!_importWalletBtn) {
        _importWalletBtn = [YQViewFactory buttonWithTitle:@"导入钱包" titleColor:WhiteColor fontSize:FIT(18) userBold:NO target:self sel:@selector(improtWalletPush)];
        [_importWalletBtn setBackgroundColor:NormalButtonColor];
        _importWalletBtn.layer.cornerRadius = 7;
    }
    return _importWalletBtn;
}

- (void)scanningAction {
    //扫描
}

- (void)showKeystoreAction {
    //什么是keystore
}

- (void)improtWalletPush {
    //导入钱包
}

@end
